<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div id="app">
      <h2>{{date}}</h2>
      <h2>{{date | formatDate}}</h2>
  </div>
  <script src="./vue.js"></script>
  <script>
      Vue.filter("formatDate",function(date) {
        let y = date.getFullYear()
          let m = date.getMonth()
          let d = date.getDate()
          let H = date.getHours()
          let M = date.getMinutes()
          let S = date.getSeconds()

          m = m<10? '0' + m : m
          d = d<10? '0' + d : d
          H = H<10? '0' + H : H
          M = M<10? '0' + M : M
          S = S<10? '0' + S : S
          
          return `${y}-${m}-${d} ${H}:${M}:${S}`
      })

    var vm = new Vue({
      el:'#app',
      data:{
          date: new Date()
      },
      methods:{
      }
     });

     setInterval(()=>{
         vm.date = new Date()
     })
  </script>
</body>
</html>
